package core

import (
	"errors"
	"fmt"
)

func NewAdapter(conf *ClusterConf) (registrar Registrar, err error) {
	switch conf.CenterType {
	case RegCenterEtcd:
		registrar, err = NewEtcdRegistrar()
	case RegCenterZookeeper:
		registrar, err = NewZookeeperRegistrar()
	case RegCenterConsul:
		registrar, err = NewConsulRegistrar()
	case RegCenterEureka:
		registrar, err = NewEurekaRegistrar()
	case RegCenterNacos:
		registrar, err = NewNacosRegistrar()
	default:
		return nil, errors.New(fmt.Sprintf("can not support this adapter:%s", conf.CenterType))
	}
	if err != nil {
		return nil, err
	}
	//err = registrar.Connect(conf)
	return
}
